package com.ohuang.lib;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.file.CopyOption;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;

public class Test
{

    public static void main(String...args) throws IOException {
//        fileChannel();

    }

    private static void copyFileUsingJava7Files(File source, File dest)
        throws IOException {
           Files.copy(source.toPath(), dest.toPath());
    }

    private static void fileChannel() throws IOException {
        long start = System.currentTimeMillis();
        File sourceFile = new File("D:/a/a.zip");
        FileInputStream fis = new FileInputStream(sourceFile);
        FileChannel fisChannel = fis.getChannel();
        FileOutputStream fos = new FileOutputStream("D:/a/b.zip");
        FileChannel fosChannel = fos.getChannel();
        //将fisChannel通道的数据，写入到fosChannel通道
        fisChannel.transferTo(0, fisChannel.size(), fosChannel);
        fis.close();
        fos.close();
        long end = System.currentTimeMillis();
        System.out.println("耗时=" + (end - start) + "ms");
    }



}
